{extend name="public/base" /}
{block name="head"}
<style type="text/css">
	.layui-form{padding: 10px;overflow: hidden;zoom: 1;}
</style>
{/block}
{block name="body"}
<div class="boke-wrap">
	<form class="layui-form" method="post">

		<div class="layui-form-item">
			<label class="layui-form-label">权限组名字</label>
			<div class="layui-input-inline">
				<input type="text" name="group_name" placeholder="请输入权限组名字" class="layui-input" lay-verify="required">
			</div>
		</div>
    <table class="layui-table layui-form">
        <thead>
          <tr>
            <th width="3%">
            	<input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose">
            </th>
						<th width="12%">菜单</th>
						<th width="6%">url</th>
						<th width="13%">验证参数</th>
						<th width="3%">允许post</th>
						<th width="13%">验证</th>
          </tr> 
        </thead>
        <tbody>
        	{volist name="menu_list" id="menu"}
					<tr>
						<td><input type="checkbox" name="menu_id[{$menu.id}]" lay-skin="primary" value="{$menu.id}" class="menu_id" ></td>
						<td>{$menu.menu_name}</td>
						<td>{$menu.url}</td>
						<td><input type="text" name="param[{$menu.id}]" class="layui-input" ></td>
						<td>
							{if condition="$menu['is_post'] == 1"}
								<input type="checkbox" name="is_post[{$menu.id}]" lay-skin="primary" value="1" checked >
							{else/}
								<input type="checkbox" name="is_post[{$menu.id}]" lay-skin="primary" value="0" disabled="disabled">
							{/if}
						</td>
						<td>
						{if condition="$menu['is_accept'] == 1"}
				      <select name="is_accept[{$menu.id}]">
				        <option value="1">通过</option>
				        <option value="0">不通过</option>
				      </select>
						{else/}
							<input type="text" class="layui-input" value="不通过" disabled="disabled">
							<input type="hidden" name="is_accept[{$menu.id}]" value="0">
						{/if}
						</td>
					</tr>
        	{/volist}
        </tbody>
    </table>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

	<script type="text/javascript">

		layui.use(['form'], function(){
	  	var form = layui.form();

	    //全选
	    form.on('checkbox(allChoose)', function(data){
	      var child = $(data.elem).parents('table').find('.menu_id');
	      child.each(function(index, item){
	          item.checked = data.elem.checked;
	      });
	      form.render('checkbox');
	    });

			form.on('submit(formDemo)', function(data){
				$.ajax({ 
					type: "post", 
					url: data.form.action, 
					data: data.field,
					dataType: 'json', 
					success: function(result){ 
						if(result['code'] == 1){
							parent.document.location.reload();
							parent.layer.closeAll();
							parent.layer.msg(result['msg']);
						}else{
							layer.msg(result['msg']);
							$(that).removeAttr("disabled");
						}
					} 
				});

				return false;
			});

		})
	</script>
</div>
{/block}




		